
<?php
    require('db_connection.php');

if (isset($_COOKIE["firstName"]))
{}
else
{
        echo"'<script>document.location.href='index.php'</script>'";
}


?>

<!doctype html public "-//W3C//DTD HTML 4.01//EN">

<html>
   <head>
      <title>La Union Online Library System</title>
      <meta http-equiv="generator" content="PHP Designer 2005" />
      <style type="text/css">
        @import url(style.css);
      </style>
   </head>

   <body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000" class=''>


    <table width='80%' align='center' class='content'>
        <tr><td colspan='2'><img src='images/banner.jpg'></td></tr>
            <tr><td align='right' colspan='2' class='logout'><?php require ('loginout.php');?></td></tr>
        <tr><td width='70%'>
            <table width='100%' cellpadding='5' class='outerframe2'>
                <tr align='center'><td class='button' width='25%'><a href='libprofileview.php' name='library' title='Library' class='button'><img src='images/library.png'><br />Library</a></td>
                    <td class='button' width='25%'><a href='adminentry.php' name='admin' title='Administrator'><img src='images/admin.png'><br />Administrator</a></td>
                    <td class='button' width='25%'><a href='catalog.php' name='catalog' title='Catalog'><img src='images/catalog.png'><br />Catalog</a></td></tr>
                <tr align='center'><td class='button'><a href='cliententry.php' name='client' title='Client'><img src='images/client.png'><br />Client</a></td>
                    <td class='button'><a href='circulation.php' name='circulation' title='Circulation'><img src='images/circulation.png'><br />Circulation</a></td>
                    <td class='button'><a href='search.php' name='search' title='Search'><img src='images/search.png'><br />Search</a></td></tr>
                <tr align='center'><td class='button'><a href='inventory.php' name='Report' target='_blank' title='Report'><img src='images/report.png'><br />Reports</a></td>
                    <td class='button'><a href='newsentry.php' name='news' target='_blank' title='News'><img src='images/news.png'><br />News</a></td>
                    <td class='button'><a href='about.php' name='about' target='_blank' title='About'><img src='images/about.png'><br />About</a></td></tr>
                    <tr align='center'><td class='button'><a href='help.php' name='help' target='_blank' title='Help'><img src='images/help.png'><br />Help</a></td><td></td><td></td></tr>
            </table>
            </td>
            <td valign='top' width='30%'>
                <table width='100%' class='outerframe2'>
                <tr><td class='title'>Library Collection Status</td></tr>
                <tr><td height='15'></td></tr>
                <?php
                    require('db_connection.php');
                    $query = "SELECT * FROM tblcirculation WHERE status LIKE 'borrowed'";
                    $result = mysql_query($query);

                    $libraryNo = $_COOKIE['libraryNo'];

                        while ($row = mysql_fetch_array($result))
                        {
                            //echo "<tr><td></td></tr>";
                            $materialID = $row['materialID'];
                            $libraryNotmp = $row['libraryNo'];
                            if($libraryNo==$libraryNotmp)
                            {
                                $ctr1++;
                            }
                        }
                    $query = "SELECT * FROM tblcirculation WHERE status LIKE 'reserved'";
                    $result = mysql_query($query);

                    $libraryNo = $_COOKIE['libraryNo'];

                        while ($row = mysql_fetch_array($result))
                        {
                            //echo "<tr><td></td></tr>";
                            $materialID = $row['materialID'];
                            $libraryNotmp = $row['libraryNo'];
                            if($libraryNo==$libraryNotmp)
                            {
                                $ctr2++;
                            }
                        }
                    $sum=$ctr1+$ctr2;
                    $sql1 = "SELECT * FROM tblcollection WHERE libraryNo='$libraryNo'";
                    $result1 = mysql_query($sql1);
                    while ($row = mysql_fetch_array($result1))
                    {
                        $copyNo = $row['copyNo'];
                        $ctr = $ctr + $copyNo;
                    }
                    $ctr=$ctr-$sum;
                    //$ctr1 = mysql_num_rows($result1);
                 echo "<tr><td>Book In ($ctr)</td></tr>";

                 echo "<tr><td>Book Out (<a href='bookborrowed.php' title='Book Out'>$ctr1</a>)</td></tr>";

                 echo "<tr><td>Book Reserved (<a href='bookreserved.php' title='Book Reserved'>$ctr2</a>)</td></tr>";
                ?>
                </table>
            </td>
         </tr>
         <tr><td align='center' colspan='2'><?php require ('copyright.php')?></td></tr>
    </table>
   </body>
</html>
